package com.chapter8;


public class LinkedList {

	Node head;
	Node tail;
	
	LinkedList(int value){
		head=new Node(value);
		head.next=null;
		head.previous=null;
		tail=head;
	}
	
	LinkedList(){
		
	}
	
	public void traverse(){
		Node current=head;
		while(current!=null){
			System.out.print(current.value+ " ");
			current=current.next;
		}
	}
	public void insert(int value){
		if(head==null){
			head=new Node(value);
			head.next=null;
			head.previous=null;
			tail=head;
			return ;
		}
		Node node=new Node(value);
		Node current=head;
		while(current.next!=null)
			current=current.next;
		current.next=node;
		node.previous=current;
		node.next=null;
	}
}
